package cn.edu.zut.qixiang.controller;

import cn.edu.zut.qixiang.service.WeatherHourlyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author 86178
 */
@RestController
@RequestMapping("/hourly")
public class WeatherHourlyController {

    @Autowired
    private WeatherHourlyService weatherHourlyService;
    @Autowired
    private WeatherHourlyService windStatsService;

    @GetMapping("/stormDays")
    public Integer getStormDaysCount() {
        return weatherHourlyService.getStormRainDaysCount();
    }

    @GetMapping("/windyDays")
    public Integer getWindyDaysCount() {
        return windStatsService.countWindyDays();
    }

    @GetMapping("/data")
    public ResponseEntity<Map<String, Object>> getHourlyData(
            @RequestParam String district,
            @RequestParam String date) {
        Map<String, Object> result = weatherHourlyService.getHourlyChartData(district, date);
        return ResponseEntity.ok(result);
    }
}